﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Documents;
using System.Windows.Shapes;
using System.Windows.Media;
using System.Windows;

namespace Relay.UI.Controls.Docking.Primitives {
    internal class SplitterAdorner : Adorner {
        #region Fields
        private Rectangle _rect = new Rectangle();
        private TranslateTransform _transform = new TranslateTransform();
        #endregion

        #region Constructor
        public SplitterAdorner(UIElement element) : base(element) {
            SnapsToDevicePixels = true;
            _rect.Fill = new SolidColorBrush(SystemColors.HighlightColor) {
                Opacity = 0.5
            };

            _rect.RenderTransform = _transform;
            AddVisualChild(_rect);
        }
        #endregion

        #region Properties
        public double X {
            get { return _transform.X; }
            set { _transform.X = value; }
        }

        public double Y {
            get { return _transform.Y; }
            set { _transform.Y = value; }
        }
        #endregion

        #region Overrides
        protected override Visual GetVisualChild(int index) {
            if (index != 0) throw new ArgumentOutOfRangeException("index");
            return _rect;
        }

        protected override int VisualChildrenCount {
            get {
                return 1;
            }
        }

        protected override Size ArrangeOverride(Size finalSize) {
            _rect.Arrange(new Rect(new Point(), finalSize));
            return finalSize;
        }
        #endregion
    }
}
